﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Xaml.Data;

namespace CrmField.Win8App.Common
{
    public sealed class DateTimeToStringConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, string language)
        {
             if (value is DateTime)
                return value.ToString();
            else
                return string.Empty;
        }

        public object ConvertBack(object value, Type targetType, object parameter, string language)
        {
            DateTime dateTime;
            if (value is string && DateTime.TryParse(value.ToString(), out dateTime))
                return dateTime;
            else
                return string.Empty;
        }
    }
}
